<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js应用01</title>
</head>
<body>
<h1>js应用01</h1><hr>
<button id="btnClick01">点我</button>
<script>
    function Person(name,age){
        this.name = name;
        this.age = age;
        this.toString = function(){
            return "人的姓名是："+this.name+"，他的年龄是："+this.age;
        }
    }



    // 这里是定义
    function loadFun(){
        alert("加载了");
    }

    function addText(){
        alert("点击了按钮");
        document.write(new Person("郑丰华",30).toString());
    }

    // 这个是页面加载直接触发
    window.onload = function(){
        loadFun();  // 这里是调用执行

        var obj = document.getElementById("btnClick01");
        if(obj!=undefined){
            obj.addEventListener("click",addText,false);
        }
    }



</script>
</body>
</html>